#include <cassert>

#include "wrappers.h"

getpid_mock_fn g_getpid_mock =
  [](void) -> pid_t { return static_cast<pid_t>(1337); };
extern "C" pid_t __wrap_getpid(void) {
  assert(g_getpid_mock);
  return g_getpid_mock();
}

scandir_mock_fn g_scandir_mock;
extern "C" int __wrap_scandir(const char *dirp,
    struct dirent ***namelist,
    int (*filter)(const struct dirent *),
    int (*compar)(const struct dirent **, const struct dirent **)) {
  assert(g_scandir_mock);
  return g_scandir_mock(dirp, namelist, filter, compar);
}

fopen_mock_fn g_fopen_mock =
  [](const char *, const char *) -> FILE* { return NULL; };
extern "C" FILE* __wrap_fopen(const char *filename, const char *mode) {
  assert(g_fopen_mock);
  return g_fopen_mock(filename, mode);
}

fread_mock_fn g_fread_mock;
extern "C" size_t __wrap_fread(void *buffer, size_t size, size_t count, FILE *stream) {
  assert(g_fread_mock);
  return g_fread_mock(buffer, size, count, stream);
}

fclose_mock_fn g_fclose_mock = [](FILE *stream) { return 0; };
extern "C" int __wrap_fclose(FILE *stream) {
  assert(g_fclose_mock);
  return g_fclose_mock(stream);
}
